package com.example.work4

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.work4.adapter.MomentsAdapter
import com.example.work4.common.ImageUtil
import com.example.work4.http.MomentRetrofitImp
import com.example.work4.view.StatusBar

class MomentsActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_moments)
        StatusBar.setStatusBarAsBlue(window)
        init()
    }


    var adapter:MomentsAdapter=MomentsAdapter(this)

    var momentsListView:RecyclerView? = null

    var apiMoment = MomentRetrofitImp();

    val imageUtil = ImageUtil(this)


    fun init(){
        val text = findViewById<TextView>(R.id.textView5)
        val avatarView = findViewById<ImageView>(R.id.avatar)
        val id = intent.getIntExtra("id",-1)
        val avatar = intent.getStringExtra("avatar")
        val nickname = intent.getStringExtra("nickname")
        text.setText(nickname)
        imageUtil.GlideLoadCenterCrop(avatar!!,avatarView)
        momentsListView=findViewById(R.id.momentRecyclerView)
        momentsListView?.layoutManager= LinearLayoutManager(this)
        apiMoment.context = this;
        apiMoment.getMomentsById(id.toLong(), adapter, momentsListView!!)
    }



}